<html>
    <title>FIFA Chrome Extension</title>
    <head>
        <script type="text/javascript" src="http://gce-fifa-worldcup.googlecode.com/svn/trunk/gce-fifa-worldcup/jquery-1.3.2.min.js">
        </script>
        <script type="text/javascript" src="http://gce-fifa-worldcup.googlecode.com/svn/trunk/gce-fifa-worldcup/common.js?1234">
        </script>
    </head>
    <script>
        // assign css dynamically
        var fileref = document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        if (chrome.i18n.getMessage("@@bidi_dir") == "ltr") 
            fileref.setAttribute("href", "../css/content.css?1234");
        else 
            fileref.setAttribute("href", "../css/content_bidi.css?1234");
        document.getElementsByTagName("head")[0].appendChild(fileref);
        
        // get url params
        function gup(name){
            name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
            var regexS = "[\\?&]" + name + "=([^&#]*)";
            var regex = new RegExp(regexS);
            var results = regex.exec(window.location.href);
            if (results == null) 
                return "";
            else 
                return results[1];
        }
        
        closeWindow = function(){
            setTimeout(function(){
                window.close();
            }, 20000); // Close the window after 20 seconds.
        }
        
        function shareFacebook(strUrl, strTitle){
            chrome.tabs.create({
                url: String.format(share_facebook, URLEncode(strUrl), escape(strTitle.replaceLatinChar().split("%23").join("")))
            });
        }
        
        function shareBuzz(strUrl, strTitle){
            chrome.tabs.create({
                url: String.format(share_buzz, URLEncode(strUrl), strTitle.replaceLatinChar().split("%26%23039%3B").join("'").split("%23").join(""))
            });
        }
        
		function shareTwitter(strUrl, strTitle){
		    $.post("http://goo.gl/api/url", {
		        user: "toolbar@google.com",
		        url: strUrl,
		        auth_token: doit(strUrl)
		    }, function(data){
		        if (data.short_url != undefined) {        
		            chrome.tabs.create({
		                url: String.format(share_twitter, strTitle.replaceLatinChar().split("%26%23039%3B").join("'") + " " + URLEncode(data.short_url))
		            });
		        }
		    }, "json");
		}
    </script>
    <body onload="closeWindow()">
        <div>
            <img src="../img/fifacom.gif" alt="" />
        </div>
        <script>
            document.write(localStorage[gup("id")]);
        </script>
    </body>
</html>
